﻿Imports System
Imports System.Drawing
Imports System.Drawing.Text

Public Class Form1

    Public VERSION = Date.Now.ToString("yyyy.mm.dd.0")

    Public Class CSkin2
	Public SkinName As String
	Public DrawWide As Boolean
	Public DrawDriveLetter As Boolean

	Public FontName As String
	Public FontSize As Integer
	Public FontColor As String
	Public FontRect As Rectangle

	Public RxImgRect As Rectangle
	Public RxImgPath As New List(Of String)

	Public WxImgRect As Rectangle
	Public WxImaPath As New List(Of String)
End Class



Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 '保存先のファイル名
		Dim fileName As String = "sample.xml"

		'保存するクラス(SampleClass)のインスタンスを作成
		Dim s As New CSkin2()

		s.SkinName = "Default"
		s.DrawWide = False
		s.DrawDriveLetter = False

		s.FontName = "Tahoma"
		s.FontSize = 6
		s.FontColor = ColorTranslator.ToHtml(Color.White)
		s.FontRect = New Rectangle(0, 8, 8, 8)

s.RxImgPath.Add("")
s.RxImgPath.Add("")
s.RxImgPath.Add("")

s.WxImaPath.Add("")

		'XmlSerializerオブジェクトを作成
		'オブジェクトの型を指定する
		Dim serializer As New System.Xml.Serialization.XmlSerializer(GetType(CSkin2))
		'書き込むファイルを開く（UTF-8 BOM無し）
		Dim sw As New System.IO.StreamWriter( _
			fileName, False, New System.Text.UTF8Encoding(False))
		'シリアル化し、XMLファイルに保存する
		serializer.Serialize(sw, s)
		'ファイルを閉じる
		sw.Close()

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
	'保存元のファイル名
		Dim fileName As String = "sample.xml"

		'XmlSerializerオブジェクトを作成
		Dim serializer As New System.Xml.Serialization.XmlSerializer(GetType(CSkin2))
		'読み込むファイルを開く
		Dim sr As New System.IO.StreamReader(fileName, New System.Text.UTF8Encoding(False))
		'XMLファイルから読み込み、逆シリアル化する
		Dim obj As CSkin2 = DirectCast(serializer.Deserialize(sr), CSkin2)
		'ファイルを閉じる
		sr.Close()

End Sub
End Class
